dragicon: Add a default drag icon for GskRenderNode
authorBenjamin Otte <otte@redhat.com>
Fri, 20 Aug 2021 03:51:20 +0000 (05:51 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 30 Aug 2021 04:02:16 +0000 (06:02 +0200)
Somebody should make this default drag icon machinery pluggable.

gtk/gtkdragicon.c

index b8b31671f997f17f321b94aa9b64e34a19be5f98..a58cf474dc1e69d67a09364a21f51bbb9c55fd4c 100644 (file)
@@ -31,7 +31,9 @@
 
 /* for the drag icons */
 #include "gtkcolorswatchprivate.h"
+#include "gtkimage.h"
 #include "gtklabel.h"
+#include "gtkrendernodepaintableprivate.h"
 #include "gtktextutil.h"
 
 
@@ -555,6 +557,25 @@ gtk_drag_icon_create_widget_for_value (const GValue *value)
 
       return picture;
     }
+  else if (G_VALUE_HOLDS (value, GSK_TYPE_RENDER_NODE))
+    {
+      GskRenderNode *node;
+      GdkPaintable *paintable;
+      graphene_rect_t bounds;
+      GtkWidget *image;
+
+      node = gsk_value_get_render_node (value);
+      if (node == NULL)
+        return NULL;
+      
+      gsk_render_node_get_bounds (node, &bounds);
+      paintable = gtk_render_node_paintable_new (node, &bounds);
+      image = gtk_image_new_from_paintable (paintable);
+      gtk_image_set_icon_size (GTK_IMAGE (image), GTK_ICON_SIZE_LARGE);
+      g_object_unref (paintable);
+
+      return image;
+    }
   else
     {
       return NULL;